package com.xisan.practice.aop.advice;

import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.stereotype.Component;

import java.time.LocalDateTime;

@Aspect
@Component
public class TestAdvice {
    @Pointcut("@annotation(com.xisan.practice.aop.annotation.GlobalTime)")
    public void eatCarrot(){}

    @Around("eatCarrot()")
    public void handlerRpcResult(ProceedingJoinPoint point) throws Throwable {
        System.out.println("开始时间" + LocalDateTime.now());
        // 调用TestServiceImpl.eatCarrot()的方法，可视情况决定是否运行
        point.proceed();
        System.out.println("结束时间" + LocalDateTime.now());
    }
}
